<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Log;

class Testing
{
    /**
     * Handle an incoming request.
     * 仅限测试环境接口
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        try{
            $env = env('APP_ENV');
            if($env === 'production'){
                return response()->json(["code" => -1, "msg" => '测试接口生产环境不允许访问', "data" => []]);
            }
        }catch (\Exception $e){
            Log::emergency(ClientVerify::class,['msg' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine()]);
            return response()->json(["code" => -1, "msg" => '测试接口生产环境不允许访问', "data" => []]);
        }
        return $next($request);
    }
}
